<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios</title>
</head>
<body>

<h1>jquery-axios.html</h1>
<button onclick="doAxiosGet()">axios.get</button>
<button onclick="doAxiosPost()">axios.post</button>
<div id="result"></div>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>

    function doAxiosGet() {
        axios.get('http://localhost/doAjaxGet')
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    }

    function doAxiosPost() {
        // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        axios.post('http://localhost/doAjaxPost', {
            id: '2',
            name: '电脑',
            remark: '游戏本'
        })
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    }

</script>

</body>
</html>
